<template>
	<view class="container">
		<view class="" @click="getKnowledges">
			测试request
		</view>
		<view class="bgc2672 w100 pd30" @click="add">
			测试pinia{{counter.count}}

		</view>
		<view class="" @click="handleScanCode">
			测试扫码
		</view>
		<view class="" @click="getUuid">
			测试uuid生成
		</view>
		<view class="" @click="Phone">
			测试加密
		</view>
	</view>
</template>

<script setup>
	import {
		getKnowledge
	} from '@/api/index';
	import {
		useCounterStore
	} from '@/stores/counter.js'
	import {
		scanCode,
		generateUUID,
		encryptPhone
	}
	from '@/utils/common.js'
	const counter = useCounterStore()

	const add = () => {
		counter.count = 5
	}

	const getKnowledges = async () => {
		const params = {
			org_id: 1
		}
		try {
			// 调用接口获取数据
			const res = await getKnowledge(params);
			knowledgeData.value = res;
		} catch (error) {

			console.error('Error fetching knowledge:', error);
		}

	};

	const handleScanCode = async () => {
		console.log('开始扫码...');
		try {
			const result = await scanCode(); // 等待扫码结果
			console.log('扫码成功，结果为：', result);
		} catch (error) {
			console.error('扫码失败：', error); // 打印失败信息
		}
	};
	const getUuid = () => {
		const uuid = generateUUID();
		console.log(uuid);
	}
	const Phone = () => {
		const phone = encryptPhone('13723631320')
		console.log(phone);
	}
</script>

<style lang="less">
	.container {
		padding: 20rpx;
	}
</style>